package com.wxxymaker.edu.service;

import com.blade.ioc.annotation.Bean;
import com.wxxymaker.edu.model.entity.ImageInfo;
import com.wxxymaker.edu.utils.TimeUtils;
import io.github.biezhi.anima.Anima;
import lombok.extern.slf4j.Slf4j;

/**
 * @AUTHOR soft
 * @DATE 2018/9/8 20:46
 * @DESCRIBE 图片
 */
@Slf4j
@Bean
public class ImageService implements Service<ImageInfo> {


    @Override
    public ImageInfo add(ImageInfo imageInfo) {
        imageInfo.setTime(TimeUtils.getTime());
        boolean rollback = Anima.atomic(() -> {
            Integer pk = imageInfo.save().asInt();
            imageInfo.setId(pk);
        }).catchException(e -> {
            log.error("保存失败! {}", e.getMessage());
        }).isRollback();
        return rollback ? null : imageInfo;
    }

    @Override
    public ImageInfo delete(Object pk) {
        return null;
    }

    @Override
    public boolean change(ImageInfo imageInfo) {
        return false;
    }

    @Override
    public ImageInfo byId(Object pk) {
        return null;
    }
}
